﻿
@{
    ViewBag.Title = "RoleInfo";
    Layout = "~/Views/Shared/_LayoutForEUI.cshtml";
    var Role = ViewBag.ROLE as SGArchiveSystem7xDB.T_Role;
}
<div>
    <div style="padding-top:10px">
        <input class="easyui-textbox" style="width:95%" label="@ViewBag.Text1:" labelwidth="80px" labelalign="right" id="Role_RoleInfo_txtName" data-options="required:true" />
    </div>
    <div style="padding-top:10px">
        <input class="easyui-textbox" style="width:95%" label="@ViewBag.Text2" labelwidth="80px" labelalign="right" id="Role_RoleInfo_txtRemark" />
    </div>
    <div style="padding-top:10px;display:none">
        <select class="easyui-combobox" style="width:95%" label="浏览密级:" labelwidth="80px" labelalign="right" id="Role_RoleInfo_cmbMJ" editable="false" panelHeight="auto">
            @{
                var listMJ = ViewBag.MJ as List<SGArchiveSystem7x.Models.CComboboxModel>;
                foreach (var n in listMJ)
                {
                    <option value="@n.ID">@n.Text</option>
                }
            }

        </select>
    </div>
    @{
        var list = ViewBag.Model as List<SGArchiveSystem7x.Models.CComboboxModel>;
        foreach (var n in list)
        {
            <div style="padding-top:10px">
                <select class="easyui-combobox" style="width:95%" label="@n.Text" labelwidth="80px" labelalign="right" id="Role_RoleInfo_cmbModel_@n.ID" editable="false" panelHeight="auto">
                    @{ 
                        if(SGArchiveSystem7x.Models.Language._nowLanguage == SGArchiveSystem7xDB._VersionLanguage._Chs)
                        {
                            <option value="0">禁用</option>
                            <option value="1">启用</option>
                        }
                        else
                        {
                            <option value="0">Stop</option>
                            <option value="1">Enable</option>
                        }
                    }
                   
                </select>
            </div>
        }
    }
    <div style="padding-top:10px;display:none">
        <select class="easyui-combobox" style="width:95%" label="工作台:" labelwidth="80px" labelalign="right" id="Role_RoleInfo_workSpaceType" editable="false" panelHeight="auto">
            <option value="0">个人工作台</option>
            <option value="1">数据工作台</option>
        </select>
    </div>
    <div style="padding-top:10px">
        <select class="easyui-combobox" style="width:95%" label="@ViewBag.Text3" labelwidth="80px" labelalign="right" id="Role_RoleInfo_cmbStatus" editable="false" panelHeight="auto">
           @{ 
                        if(SGArchiveSystem7x.Models.Language._nowLanguage == SGArchiveSystem7xDB._VersionLanguage._Chs)
                        {
                            <option value="0">禁用</option>
                            <option value="1">启用</option>
                        }
                        else
                        {
                            <option value="0">Stop</option>
                            <option value="1">Enable</option>
                        }
                    }
        </select>
    </div>
</div>
<div data-options="region:'south',border:false" style="text-align:right;padding-top:5px;padding-right:20px">
    <a class="easyui-linkbutton button-blue" data-options="iconCls:'icon-ok'" href="javascript:void(0)" style="width:100px" onclick="save()">@ViewBag.Text9</a>
    @*<a class="easyui-linkbutton button-orange" data-options="iconCls:'icon-cancel'" href="javascript:void(0)" style="width:100px" onclick="closeWin()">取消</a>*@
</div>
<script>
    $(document).ready(function () {
        $('#Role_RoleInfo_txtName').textbox("setValue",'@Role.ROLE_NAME');
        $('#Role_RoleInfo_txtRemark').textbox("setValue",'@Role.ROLE_REAMARK');
        $('#Role_RoleInfo_cmbStatus').combobox('setValue',@Role.ROLE_STATUS);
        var imj = @Role.ROLE_MJ;
        if(imj > 0)
            $('#Role_RoleInfo_cmbMJ').combobox('setValue',imj);

        var qx = '@Role.ROLE_V01';
        var strs = new Array(); //定义一数组
        strs = qx.split(","); //字符分割

        var list = $('select[id^="Role_RoleInfo_cmbModel_"]');
        for (var i = 0; i < list.length; i++) {
            var id = list[i].id;
            var ids = id.split('_');
            var mid = ids[3];
            for (var j = 0; j < strs.length; j++) {
                //alert(strs[j]);
                if (strs[j] == mid) {
                    $('#' + id).combobox('setValue', 1);
                    break;
                }
            }
        }

    });

    function save() {
        $.messager.confirm("@ViewBag.Text4", "@ViewBag.Text5", function (r) {
            if (r) {
                var name = $('#Role_RoleInfo_txtName').val();
                if (name == '') {
                    $.messager.alert('@ViewBag.Text4', '@ViewBag.Text6', 'error');
                    return;
                }

                var s = '';
                var list = $('select[id^="Role_RoleInfo_cmbModel_"]');
                for (var i = 0; i < list.length; i++) {
                    var str = list[i].id;
                    var strs = str.split('_');

                    if ($('#' + str).combobox('getValue')==1)
                         s += strs[3] + ',';
                }

                var remark = $('#Role_RoleInfo_txtRemark').val();
                var status = $('#Role_RoleInfo_cmbStatus').combobox('getValue');
                var mj = $('#Role_RoleInfo_cmbMJ').combobox('getValue');
                var space = $('#Role_RoleInfo_workSpaceType').combobox('getValue');

                $.ajax({
                    method: "post",
                    dataType: "text",
                    url: "/Role/SaveRole",
                    data: { id: @Role.ROLE_ID, name: name, remark: remark, status:status, au:s, mj: mj, space: space },
                    success: function (data) {
                        if (data == '1') {
                             $.messager.alert('@ViewBag.Text4', '@ViewBag.Text7', 'info');
                            parent.UpdateList();
                        }
                        else
                            $.messager.alert('@ViewBag.Text4', '@ViewBag.Text7', 'error');
                        //$('#ArchiveWord_Index_grid').datagrid('reload');   // 重新载入当前页面数据
                    }
                })
            }
        })
    }
</script>